#pragma once

#include "Vector2D.h"
#include <d3d9.h>
#include <d3dx9.h>

class Transform {
private:
	Vector2D pos; // position
	float rot; // rotation
	Vector2D scl; // scale
public:
	Transform();
	Transform(const Vector2D& position);
	Transform(const D3DXVECTOR3& position);
	Transform(float x, float y);
	Transform(const Vector2D& position, float rotation);
	Transform(const D3DXVECTOR3& position, float rotation);
	Transform(float x, float y, float rotation);
	Transform(const Vector2D& position, const Vector2D& scale);
	Transform(const D3DXVECTOR3& position, const D3DXVECTOR3& scale);
	Transform(float x, float y, float xScale, float yScale);
	Transform(const Vector2D& position, float rotation, const Vector2D& scale);
	Transform(const D3DXVECTOR3& position, float rotation, const D3DXVECTOR3& scale);
	Transform(float x, float y, float rotation, float xScale, float yScale);
	~Transform();

	/*
	Get the position of the Transform.
	@param	out			Vector to store the data in.
	*/
	void GetPosition(Vector2D* out) {
		if (out != 0) {
			out->x = pos.x;
			out->y = pos.y;
		}
		return;
	}
	/*
	@return	Position in x.
	*/
	float GetX() { return pos.x; }
	/*
	@return Position in y.
	*/
	float GetY() { return pos.y; }
	/*
	@return	Rotation around the Z axis.
	*/
	float GetRotation() { return rot; }
	/*
	Get the scale of the Transform.
	@param	out			Vector to store the data in.
	*/
	void GetScale(Vector2D* out) {
		if (out != 0) {
			out->x = scl.x;
			out->y = scl.y;
		}
		return;
	}
	/*
	@return	Scale in x.
	*/
	float GetScaleX() { return scl.x; }
	/*
	@return	Scale in y.
	*/
	float GetScaleY() { return scl.y; }

	/*
	Get the translation matrix for the Transform.
	@param	out			Matrix to store the data in.
	*/
	void TranslationMatrix(D3DXMATRIX* out) {
		if (out != 0) {
			D3DXMatrixTranslation(out, pos.x, pos.y, 0.f);
		}
		return;
	}
	/*
	Get the rotation matrix for the Transform.
	@param	out			Matrix to store the data in.
	*/
	void RotationMatrix(D3DXMATRIX* out) {
		if (out != 0) {
			D3DXMatrixRotationZ(out, rot);
		}
		return;
	}
	/*
	Get the scale matrix for the Transform.
	@param	out			Matrix to store the data in.
	*/
	void ScaleMatrix(D3DXMATRIX* out) {
		if (out != 0) {
			D3DXMatrixScaling(out, scl.x, scl.y, 0.f);
		}
		return;
	}

	/*
	Override the position in x with a new one.
	@param	xPosition	New position in x.
	*/
	void SetPositionX(float xPosition) {
		pos.x = xPosition;
		return;
	}
	/*
	Override the position in y with a new one.
	@param	yPosition	New position in y.
	*/
	void SetPositionY(float yPosition) {
		pos.y = yPosition;
		return;
	}
	/*
	Override the position with a new one.
	@param	xPosition	New position in x.
	@param	yPosition	New position in y.
	*/
	void SetPosition(float xPosition, float yPosition) {
		SetPositionX(xPosition);
		SetPositionY(yPosition);
		return;
	}
	/*
	Override the position with a new one.
	@param	position	New position.
	*/
	void SetPosition(const Vector2D& position) {
		SetPosition(position.x, position.y);
		return;
	}
	/*
	Override the position with a new one.
	@param	position	New position.
	*/
	void SetPosition(const D3DXVECTOR3& position) {
		SetPosition(position.x, position.y);
		return;
	}
	/*
	Override the rotation with a new one.
	@param	rotation	New rotation around the Z axis.
	*/
	void SetRotation(float rotation) {
		rot = rotation;
		return;
	}
	/*
	Override the scale in x with a new one.
	@param	xScale		New scale in x.
	*/
	void SetScaleX(float xScale) {
		scl.x = xScale;
		return;
	}
	/*
	Override the scale in y with a new one.
	@param	yScale		New scale in y.
	*/
	void SetScaleY(float yScale) {
		scl.y = yScale;
		return;
	}
	/*
	Override the scale with a new one.
	@param	xScale		New scale in x.
	@param	yScale		New scale in y.
	*/
	void SetScale(float xScale, float yScale) {
		SetScaleX(xScale);
		SetScaleY(yScale);
		return;
	}
	/*
	Override the scale with a new one.
	@param	scale		New scale.
	*/
	void SetScale(const Vector2D& scale) {
		SetScale(scale.x, scale.y);
		return;
	}
	/*
	Override the scale with a new one.
	@param	scale		New scale.
	*/
	void SetScale(const D3DXVECTOR3& scale) {
		SetScale(scale.x, scale.y);
		return;
	}
};

